package com.framework.modules.common.channel.other;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;

/**
 * 其他支付渠道配置类
 * @author: xfy
 * @date: 2020/10/28
 */
@Component
public class OtherPayConfig {

    // 商户appid
    private String app_id="10130";

    // 渠道id
    private String channel_id="904";

    private String notify_url="http://rap.minglianshua.com:8802/api/notify/payment_otherpay_notify";
    // 页面跳转同步通知页面路径 需http://或者https://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问 商户可以自定义同步跳转地址

    private String return_url="";
    // 请求网关地址
    private String url = "https://bbc.xiudongdianzi.cn/Pay_Index.html";

    // 支付宝公钥
    public String key="2p8e2u2bx9aewrojvjyyk0m8u1lbizlo";

    /**
     * 初始化配置
     * @param configParam
     * @return
     */
    public OtherPayConfig init(String configParam) {
        if(StringUtils.isBlank(configParam)){
            return this;
        }
        JSONObject paramObj = JSON.parseObject(configParam);
        this.setApp_id(paramObj.getString("app_id"));
        this.setChannel_id(paramObj.getString("channel_id"));
        this.setNotify_url(paramObj.getString("notify_url"));
        this.setReturn_url(paramObj.getString("return_url"));
        this.setKey(paramObj.getString("pubkey"));
        this.setUrl(paramObj.getString("gateway"));
        return this;
    }

    public String getApp_id() {
        return app_id;
    }

    public void setApp_id(String app_id) {
        this.app_id = app_id;
    }


    public String getNotify_url() {
        return notify_url;
    }

    public void setNotify_url(String notify_url) {
        this.notify_url = notify_url;
    }

    public String getReturn_url() {
        return return_url;
    }

    public void setReturn_url(String return_url) {
        this.return_url = return_url;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getChannel_id() {
        return channel_id;
    }

    public void setChannel_id(String channel_id) {
        this.channel_id = channel_id;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

}

